import { defineStore } from 'pinia'
//个人中心pinia
export const userCenterStore = defineStore('userCenter', {
	state: () => {
		return {
			unRead: 0, //未读消息数量
			tab: 'accountBasic', //当前tab
			time: 0 //时间戳
		}
	},
	actions: {
		//加1
		increment() {
			this.unRead++
		},
		//减1
		decrement() {
			if (this.unRead > 0) this.unRead--
		},
		//设置未读消息数量
		setUnRead(unRead) {
			this.unRead = unRead
		},
		//设置tab
		setTab(tab) {
			this.tab = tab
		},
		//重置tab
		resetTab() {
			this.tab = 'accountBasic'
		},
		setTime() {
			this.time = new Date().getTime()
		}
	}
})
